package logic.courseSelect_logic;

import java.util.LinkedList;
import java.util.List;

import javaRMI.RMIClient;
import logic.utility_logic.CourseProduceLogicsvFactory;
import logicsv.courseProduce_logicsv.CourseProduceLogicsv;
import po.SelectRecordPO;
import resultmessage.CourseSelectRM;
import vo.CourseBasicVO;
import datasv.courseSelect_datasv.CourseSelectDatasv;
import datasv.datafactorysv.CourseSelectDatasvFactory;

public class CourseSelect {
	private CourseSelectDatasv courseSD ;
	private CourseProduceLogicsv coursePL;
	public CourseSelect(RMIClient rmi){
		courseSD = new CourseSelectDatasvFactory(rmi).create();
		coursePL = new CourseProduceLogicsvFactory(rmi).create();
	}
	public CourseSelectRM select(String courseID,String studentID){
		return courseSD.addSelectRecord(courseID, studentID);
	}
	public CourseSelectRM drop(String courseID,String studentID){
		return courseSD.deleteSelectRecord(courseID, studentID);
	}
	public List<CourseBasicVO> getStudentSecRecord(String studentID){
		LinkedList<CourseBasicVO> list = new LinkedList<CourseBasicVO>();
		for(SelectRecordPO rec :courseSD.getStudentSecRecord(studentID)){
			list.add(coursePL.getCourseBasic(rec.getCourseID()));
		}
		return list;
	}
	
}
